
<!--员工档案修改-->

<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>根据id获取的详细信息放到这里</title>
  <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
</head>
<body>
<form method="post" class="layui-form" action="">
  <div class="layui-form-item" th:each="e:${employeeInfo}">
    <div class="layui-inline">
      <div class="layui-input-bolck">
        <input th:value="${e.id}" name="id" type="hidden" autocomplete="off" class="layui-input" />
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">员工姓名</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${e.empName}" name="empName" autocomplete="off" class="layui-input" />
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">员工手机</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${e.empPhone }" name="empPhone" autocomplete="off" class="layui-input">
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">学历</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${e.empdip }" name="empdip" autocomplete="off" class="layui-input">
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">所属角色</label>
      <div class="layui-input-inline">
        <select name="roleid" class="layui-input"  >
          <!--<option value="-1">全部角色</option>-->

          <option th:each="r:${roles}" th:if="${e.roleid}==${r.id}" th:value="${r.id}" th:text="${r.description}"></option>
          <option th:each="r:${roles}" th:if="${e.roleid}!=${r.id}" th:value="${r.id}" th:text="${r.description}"></option>
        </select>
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">所属部门</label>
      <div class="layui-input-inline">
        <select name="empdpt" class="layui-input"  >
          <!--<option value="-1">全部部门</option>-->
          <option th:each="d:${department}" th:if="${e.empdpt}==${d.id}" th:value="${d.id}" th:text="${d.name}"></option>
          <option th:each="d:${department}" th:if="${e.empdpt}!=${d.id}" th:value="${d.id}" th:text="${d.name}"></option>
        </select>
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">员工状态</label>
      <div class="layui-input-inline">
        <select name="isofficial" class="layui-input">
          <option th:if="${e.isofficial}==1" th:value="1" th:text="正式员工"></option>
          <option th:if="${e.isofficial}!=1" th:value="2" th:text="非正式员工"></option>
        </select>
      </div>
    </div>
  </div>
  <div calss="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
    </div>
  </div>
</form>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
  layui.use(['form'], function () {
    var form = layui.form;
    var layer = layui.layer;
    var $ = layui.$;

    //监听提交
    form.on('submit(saveBtn)', function (data) {
      if (data.field.empdpt<0){
        alert("请选择部门");
        return false;
      }
      if(data.field.roleid<0){
        alert("请选择角色");
        return false;
      }
      $.post('/user/edit',data.field,function(res){
        if(res.data==="success"){
          alert("修改成功");
          var iframeIndex = parent.layer.getFrameIndex(window.name);
          parent.layer.close(iframeIndex);
          //通过父页面去重新加载表格
          parent.layui.table.reload('table-user');
          parent.layer.msg(res.msg);
          this.close();
        }
      })

      return false;
    });

  });
</script>
</body>
</html>